package com.fashion.service.gallery;

import com.fashion.model.gallery.RecommendText;
import com.fashion.utils.StringUtils;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Service("recommendTextService")
public class RecommendTextService {
	@Resource(name = "hibernateTemplate")
	private HibernateTemplate template;
	
	public List<RecommendText> findAll(){
        return template.find("from RecommendText order by date desc");
    }
	
	public void addRecommendText(RecommendText recommendText){
	    recommendText.setId(StringUtils.createGuid());
	    recommendText.setDate(new Date());
        template.save(recommendText);
    }
	
	public void updateRecommendText(RecommendText recommendText){
	    recommendText.setDate(new Date());
        template.update(recommendText);
    }
	
	public void delRecommendText(RecommendText recommendText){
        template.delete(recommendText);
    }
}
